package com.haoshuang.zhouzhoubang.ui.page.order.take.code

import com.haoshuang.zhouzhoubang.model.api.ApiRepo
import com.haoshuang.zhouzhoubang.model.bean.TakeOrderPayCodeBean
import com.mufeng.libs.base.BaseViewModel
import com.mufeng.libs.net.netRequest
import com.mufeng.libs.state.StateData
import com.mufeng.libs.state.StatefulMutableLiveData

class PayCodeViewModel : BaseViewModel() {

    /**
     * 订单支付二维码
     */
    val createPayQrcodeData = StatefulMutableLiveData<TakeOrderPayCodeBean>()
    fun createPayQrcode(order_id: String) = netRequest {
        start { createPayQrcodeData.value = StateData.Loading }
        request { ApiRepo.createPayQrcode(order_id)  }
        success { createPayQrcodeData.value = StateData.Success(it.data) }
        error { code, msg ->
            createPayQrcodeData.value = StateData.Error(code, msg)
        }
    }

}